#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_delete.py
# author:wmf
# datetime:2021/5/23 22:22
# software: PyCharm
'''
this is function description
'''
# import module your need

from homework10.homework10_3 import session
from homework10.homework10_3.student import User


# 根据名字删除记录
def dbDelete(name):
    students = User.get_people()
    for student in students:
        if student.name == name:
            try:
                session.delete(student)
                session.commit()
                session.close()
                return True
            except:
                print("发生错误")
    print("无此人记录!")


if __name__ == "__main__":
    dbDelete("李四")
